package top.mczhengyi.xyblog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import top.mczhengyi.xyblog.entity.Blog;

import java.util.List;

@Mapper
public interface BlogMapper extends BaseMapper<Blog> {
    @Select("SELECT `id`, `title`, `markdown`, author as authorId, reply_count as replyCount, like_count as likeCount, " +
            "classify as classifyId, placed, visible, create_time as createTime " +
            "FROM b_article " +
            "WHERE id = #{id}")
    Blog selectBlogWithId(Integer id);

    @Select("SELECT `id`, `title`, `markdown`, author as authorId, reply_count as replyCount, like_count as likeCount, " +
            "classify as classifyId, placed, visible, create_time as createTime " +
            "FROM b_article\n" +
            "ORDER BY create_time DESC")
    List<Blog> selectAllBlog();

    @Select("SELECT `id`, `title`, `markdown`, author as authorId, reply_count as replyCount, like_count as likeCount, " +
            "classify as classifyId, placed, visible, create_time as createTime " +
            "FROM b_article " +
            "WHERE visible = 1\n" +
            "ORDER BY create_time DESC")
    List<Blog> selectVisibleBlog();
}
